package com.jay.lang.reflect.intf;

import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.List;

public class TypeVariableIntf<T> {
	public static void main(String[] args) throws NoSuchMethodException,
			SecurityException {

		Method getPayments = TypeVariableIntf.class.getMethod("getPayments",
				new Class[] { String[].class, List.class });
		Type[] types = getPayments.getTypeParameters();
		if (types[0] instanceof TypeVariable) {
			System.out.println("The method has a type variable.");
			TypeVariable<?> gType = (TypeVariable<?>) types[0];
			System.out.println(gType.getBounds()[0]);
			System.out.println(gType.getName());
			System.out.println(gType.getGenericDeclaration());
		}
		types = TypeVariableIntf.class.getTypeParameters();
		if (types[0] instanceof TypeVariable) {
			System.out.println("The class has a type variable.");
			TypeVariable<?> gType = (TypeVariable<?>) types[0];
			System.out.println(gType.getBounds()[0]);
			System.out.println(gType.getName());
			System.out.println(gType.getGenericDeclaration());
		}
	}

	public <K> T getPayments(String[] payments, List<String> products) {
		return (T) (new Object());
	}

}
